package com.hfzy.ihk.facade.linkcall.enums.KnowledgeBase;

import com.hfzy.ihk.common.facade.elasticsearch.ElasticsearchTableOperation;
import com.hfzy.ihk.common.facade.elasticsearch.entity.ElasticsearchTable;

import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: ouyicong
 * @Date: 2018/8/12 16:42
 * @Description:
 */
public enum QuestionBaseOperations implements ElasticsearchTableOperation {


    deleteQuestionBase("deleteQuestionBase","删除一条学习分析", QuestionBaseTables.QUESTIONBASE),
    updateQuestionBase("updateQuestionBase","修改一条学习分析", QuestionBaseTables.QUESTIONBASE),
    addQuestionBase("addQuestionBase","添加一条学习分析", QuestionBaseTables.QUESTIONBASE),
    addKnowledgeBase("addKnowledgeBase","添加一条知识库问题",QuestionBaseTables.KNOWLEDGEBASE),
    updateKnowledgeBase("updateKnowledgeBase","更新一条知识库",QuestionBaseTables.KNOWLEDGEBASE);



    private String value;

    private String desc;

    private ElasticsearchTable belong;

    QuestionBaseOperations(String value, String desc, ElasticsearchTable belong) {
        this.value = value;
        this.desc = desc;
        this.belong = belong;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public ElasticsearchTable getBelong() {
        return belong;
    }

    @Override
    public ElasticsearchTable getBelongTable() {

        return belong;
    }



    @Override
    public String getOperationName() {
        return value;
    }

    @Override
    public String getOperationDesc() {
        return desc;
    }


    private static Map<String, QuestionBaseOperations> map = new HashMap<String, QuestionBaseOperations>();
    static {
        for (QuestionBaseOperations value : QuestionBaseOperations.values()) {
            map.put(value.getValue(), value);
        }
    }

    public  static QuestionBaseOperations fromValue(String value){

        QuestionBaseOperations table=map.get(value);

        if(table!=null){

            return table;
        }else {

            throw new IllegalArgumentException("No enum const " + QuestionBaseTables.class + "." + value);
        }

    };
}
